/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#pragma once
#include "hilog/log.h"

#ifdef HILOGF
#undef HILOGF
#endif

#ifdef HILOGE
#undef HILOGE
#endif

#ifdef HILOGW
#undef HILOGW
#endif

#ifdef HILOGI
#undef HILOGI
#endif

#ifdef HILOGD
#undef HILOGD
#endif

#ifndef NFC_LOG_DOMAIN
#define NFC_LOG_DOMAIN 0xD006000
#endif

#ifndef NFC_LOG_TAG
#define NFC_LOG_TAG "nfc-halimpl"
#endif

#ifdef LOG_LABEL
#undef LOG_LABEL
#endif

static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, NFC_LOG_DOMAIN, NFC_LOG_TAG};

#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__)

#define HILOGF(fmt, ...)                 \
    (void)OHOS::HiviewDFX::HiLog::Fatal( \
        LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define HILOGE(fmt, ...)                 \
    (void)OHOS::HiviewDFX::HiLog::Error( \
        LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define HILOGW(fmt, ...)                \
    (void)OHOS::HiviewDFX::HiLog::Warn( \
        LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define HILOGI(fmt, ...)                \
    (void)OHOS::HiviewDFX::HiLog::Info( \
        LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define HILOGD(fmt, ...)                 \
    (void)OHOS::HiviewDFX::HiLog::Debug( \
        LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__)

#define ALOGD_IF(dbg, ...) (dbg ? HILOGD(__VA_ARGS__) : (void)0)

#define ALOGI_IF(dbg, ...) (dbg ? HILOGI(__VA_ARGS__) : (void)0)

#define ALOGW_IF(dbg, ...) (dbg ? HILOGW(__VA_ARGS__) : (void)0)

#define ALOGE_IF(dbg, ...) (dbg ? HILOGE(__VA_ARGS__) : (void)0)

#define ALOGD(...) HILOGD(__VA_ARGS__)

#define ALOGE(...) HILOGE(__VA_ARGS__)

#define LOG_PRI(level, extrans, ...)  HILOGD(__VA_ARGS__) // TODO: check level

#define errorWriteLog(...) // such as: errorWriteLog(0x534e4554, "115635871");

typedef enum NciLogPriority {
  NCI_LOG_UNKNOWN = 0,

  NCI_LOG_DEFAULT,

  NCI_LOG_VERBOSE,

  NCI_LOG_DEBUG,

  NCI_LOG_INFO,

  NCI_LOG_WARN,

  NCI_LOG_ERROR,

  NCI_LOG_FATAL,

  NCI_LOG_SILENT,
} NciLogPriority;
